<?php
/**
 * Created by PhpStorm.
 * User: zhan
 * Date: 2018/10/19  15:07
 */
namespace app\pc\logic;
use app\pc\BaseModel;

class About extends  BaseModel
{

    //检测参数是否已传
    protected $ParameterDetection = [
    ];

    /**
     * 关于我们
     */
    public function index()
    {
        if($this->requestData['category']){
            $cid = $this->requestData['category'];
        }else{
            $cid = 10;
        }
//        die($cid);
        $child = db('article_category')->where(['pid'=>$cid])->select();
        if($child){
            $cid = $child[0]['id'];
        }
        $content = db('article')->where(['cid'=>$cid])->select();

        $nid = $this->articleNew->get_nav_id('关于我们');
        $nav = $this->articleNew->get_nav_category($nid,0);

        $result['content'] = $content;
        $result['nav'] = $nav;
        return $result;
    }

    /**
     * 详情
     */
    public function detail()
    {
        $id = $this->requestData['id'];
        $info = $this->articleNew->detail($id);
        $nid = $this->articleNew->get_nav_id('关于我们');
        $nav = $this->articleNew->get_nav_category($nid,0);

        $result['news_info'] = $info;
        $result['nav'] = $nav;
        return $result;
    }

    //关于我们侧边栏
//    public function nav()
//    {
//        $item = db('article_category')->where('nav_id=5 and pid=0')->select();
//        foreach($item as $key=>$value){
//            $item[$key]['url'] = __ROOT__.'/category/'.$item[$key]['id'].'.html';
//            $chlid = db('article_category')->where(['pid'=>$item[$key]['id']])->select();
//            foreach($chlid as $k=>$val){
//                $chlid[$k]['url']=__ROOT__.'/category/'.$chlid[$k]['id'].'.html';
//            }
//            $item[$key]['chlid']=$chlid;
//        };
//
//        return $item;
//    }

}
